//
//  SwiftConstants.swift
//  Adorbee
//
//  Created by amovision on 2024/11/26.
//

import UIKit

public typealias AString = NSAttributedString
public typealias MAString = NSMutableAttributedString
public typealias YHVoidBlock = () -> Void
public typealias YHBoolBlock = (Bool) -> Void
public typealias YHIntBlock = (Int) -> Void
public typealias YHAnyBlock = (Any) -> Void
public typealias YHOptAnyBlock = (Any?) -> Void
public typealias YHButtonBlock = (UIButton) -> Void

/// 计算属性
/// 根据屏幕旋转状态不同，结果也不同
public var YHScreenW: CGFloat { UIScreen.main.bounds.width } /// <
public var YHScreenH: CGFloat { UIScreen.main.bounds.height }
public var YHIsLandscape: Bool { // 当前屏幕方向是否横屏  YHScreenW > YHScreenH
  if #available(iOS 16.0, *) {
    return UIApplication.shared.windows.first?.windowScene?.interfaceOrientation.isLandscape ?? false
  } else {
    return UIDevice.current.orientation.isLandscape
  }
}

/// 懒加载属性
public let YHApplication = UIApplication.shared
public let YHUserDefaults = UserDefaults.standard
public let YHKeyWindow = UIApplication
  .shared
  .connectedScenes
  .flatMap { ($0 as? UIWindowScene)?.windows ?? [] }
  .last { $0.isKeyWindow } ?? UIWindow()

public let YHKeyWindowView = YHKeyWindow.rootViewController!.view
public let YHSafeAreaInsets = YHKeyWindow.safeAreaInsets
public let YHIsIPhoneX = YHSafeAreaInsets.bottom > 0
public let YHSafeBottomHeight: CGFloat = YHIsIPhoneX ?34:0
public let YHStatusBarHeight: CGFloat = YHIsIPhoneX ?44:20
public let YHNaviBarHeight: CGFloat = YHStatusBarHeight + 44
public let YHTabBarHeight: CGFloat = YHIsIPhoneX ?84:50
public let YHCellInset: CGFloat = YHScreenW > 400 ?20:16

public struct Theme {
  public static var light: UIColor = .systemBlue
  public static var dark: UIColor = .blue
}


